//
//  TRShareLogsTableViewCell.m
//  WeiMiLan
//
//  Created by anan on 14/12/25.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "TRShareLogsTableViewCell.h"

@implementation TRShareLogsTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setInfo:(NSDictionary *)info
{
    _info = info;
   // NSString *thumbs_upStr = [NSString stringWithFormat:@"%@",info[@"THUMBS_UP_FLAG"]];

        NSDictionary *thumbsPeoples = [info[@"USER_INFO"] firstObject];
    if (thumbsPeoples.count > 0) {
        self.imageViewUserHeader.layer.masksToBounds = YES;
        self.imageViewUserHeader.layer.cornerRadius = 16; //设置图片圆角的尺度
        [self.imageViewUserHeader sd_setImageWithURL:[NSURL URLWithString:thumbsPeoples[@"HEAD_PIC_URL"]] placeholderImage:[UIImage imageNamed:@"nodata_public"]];
        NSString *userName = thumbsPeoples[@"NAME"];
        self.labelUserName.text = userName;
  
        NSString *content = [NSString stringWithFormat:@"赞了: %@",info[@"CONTENT"]];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:content];
//        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.659 green:0.541 blue:0.306 alpha:1.000] range:NSMakeRange(0,userName.length)];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.9 green:0.5 blue:0.3 alpha:1.0] range:NSMakeRange(0,2)];
        self.labelContent.attributedText = str;
        
        
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyyMMddHHmmss"];
        NSDate *createDate = [formatter dateFromString:thumbsPeoples[@"CREATE_DATE"]];
        
        
        NSString *strTime = [NSString stringWithFormat:@"%@",[createDate ql_ToString]];
        strTime = [strTime substringFromIndex:5];
    
        
        self.labelTime.text = strTime;
    }


}

- (float)getHeight
{
    return 64;
}

- (IBAction)buttonUserDetailAction:(id)sender
{
    NSDictionary *thumbsPeoples = [self.info[@"USER_INFO"] firstObject];
    if (thumbsPeoples.count > 0) {
     [QLPlayerManager openUserHomeWithId:[thumbsPeoples ql_intForKey:@"ID"] viewController:self.viewController];
    }
//    else {
//    [QLPlayerManager openUserHomeWithId:[self.info ql_intForKey:@"ID"] viewController:self.viewController];
//    }
   
}

@end
